<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>智能助手 - 江西理工大学三江校区电科251班</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* 样式保持与主网页一致 */
        :root {
            --primary-color: #0056a6;
            --secondary-color: #ff6b00;
            --accent-color: #ff9800;
            --light-color: #f5f5f5;
            --dark-color: #333;
            --success-color: #4caf50;
            --warning-color: #ffc107;
            --danger-color: #f44336;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background: linear-gradient(rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.9)), 
                        url('https://images.unsplash.com/photo-1506905925346-21bda4d32df4?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1470&q=80');
            background-size: cover;
            background-attachment: fixed;
            background-position: center;
            color: #333;
            line-height: 1.6;
            min-height: 100vh;
        }
        
        .container {
            width: 90%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 15px;
        }
        
        /* 头部样式 */
        header {
            background: linear-gradient(135deg, var(--primary-color), #003d7a);
            color: white;
            padding: 15px 0;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            position: sticky;
            top: 0;
            z-index: 100;
        }
        
        .header-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .logo {
            display: flex;
            align-items: center;
        }
        
        .logo i {
            font-size: 2rem;
            margin-right: 10px;
        }
        
        .logo h1 {
            font-size: 1.5rem;
            font-weight: 600;
        }
        
        .logo p {
            font-size: 0.8rem;
            opacity: 0.9;
        }
        
        .mobile-menu-btn {
            display: none;
            background: none;
            border: none;
            color: white;
            font-size: 1.5rem;
            cursor: pointer;
        }
        
        nav ul {
            display: flex;
            list-style: none;
        }
        
        nav li {
            margin-left: 20px;
        }
        
        nav a {
            color: white;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s;
            padding: 8px 12px;
            border-radius: 4px;
            white-space: nowrap;
        }
        
        nav a:hover, nav a.active {
            background-color: rgba(255, 255, 255, 0.2);
        }
        
        .mr-2 {
            margin-right: 8px;
        }
        
        /* 主内容区域 */
        .main-content {
            padding: 40px 0;
        }
        
        .assistant-container {
            max-width: 1000px;
            margin: 0 auto;
            text-align: center;
        }
        
        .assistant-header {
            margin-bottom: 30px;
        }
        
        .assistant-header h2 {
            color: var(--primary-color);
            font-size: 2rem;
            margin-bottom: 15px;
        }
        
        .assistant-header p {
            color: #666;
            font-size: 1.1rem;
            max-width: 700px;
            margin: 0 auto;
        }
        
        /* 智能体容器样式 */
        .coze-container {
            width: 100%;
            max-width: 800px;
            height: 600px;
            margin: 0 auto;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            border: 1px solid #e0e0e0;
            background-color: white;
            position: relative;
        }
        
        /* 智能助手按钮样式 - 设置黄色背景 */
        .coze-container button {
            background-color: #ffeb3b !important;
            color: #333 !important;
            border: none !important;
        }
        
        .coze-container button:hover {
            background-color: #fdd835 !important;
        }
        
        /* 针对扣子智能体特定按钮的样式 */
        [class*="send-btn"], [class*="sendButton"] {
            background-color: #ffeb3b !important;
            color: #333 !important;
        }
        
        /* 加载提示 */
        .loading-indicator {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            z-index: 999;
        }
        
        .loading-spinner {
            width: 50px;
            height: 50px;
            border: 5px solid #f3f3f3;
            border-top: 5px solid var(--primary-color);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto 15px;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        /* 响应式设计 */
        @media (max-width: 768px) {
            .mobile-menu-btn {
                display: block;
            }
            
            nav ul {
                display: none;
                position: absolute;
                top: 100%;
                left: 0;
                right: 0;
                background: linear-gradient(135deg, var(--primary-color), #003d7a);
                flex-direction: column;
                padding: 15px;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            }
            
            nav ul.show {
                display: flex;
            }
            
            nav li {
                margin: 10px 0;
            }
            
            .coze-container {
                height: 500px;
            }
        }
        
        @media (max-width: 480px) {
            .coze-container {
                height: 400px;
            }
            
            .assistant-header h2 {
                font-size: 1.5rem;
            }
        }
    </style>
</head>
<body>
    <!-- 头部 -->
    <header>
        <div class="container">
            <div class="header-content">
                <div class="logo">
                    <i class="fas fa-graduation-cap"></i>
                    <div>
                        <h1>江西理工大学三江校区</h1>
                        <p>电科251班</p>
                    </div>
                </div>
                
                <button class="mobile-menu-btn">
                    <i class="fas fa-bars"></i>
                </button>
                
                <nav>
                    <ul>
                        <li><a href="p1.html"><i class="fas fa-home"></i> 首页</a></li>
                        <li><a href="p1.html#notifications"><i class="fas fa-bell"></i> 通知</a></li>
                        <li><a href="p1.html#resources"><i class="fas fa-book"></i> 学习资源</a></li>
                        <li><a href="p1.html#wall"><i class="fas fa-comments"></i> 班级墙</a></li>
                        <li><a href="ai_assistant.html" class="active" style="background-color: #0056a6; color: white; padding: 12px 20px; border-radius: 25px; font-weight: 600; box-shadow: 0 4px 12px rgba(0, 86, 166, 0.3); transition: all 0.3s ease;"><i class="fas fa-robot mr-2"></i> 智能助手</a></li>
                    </ul>
                </nav>
            </div>
        </div>
    </header>

    <!-- 主内容区域 -->
    <main class="main-content">
        <div class="container">
            <div class="assistant-container">
                <div class="assistant-header">
                    <h2><i class="fas fa-robot"></i> 班级智能助手</h2>
                    <p>欢迎使用班级智能助手，您可以在这里咨询学习问题、获取班级信息或寻求帮助。</p>
                </div>
                
                <div class="coze-container">
                    <!-- 加载提示 -->
                    <div class="loading-indicator" id="loadingIndicator">
                        <div class="loading-spinner"></div>
                        <p>智能助手正在加载中...</p>
                    </div>
                    
                    <!-- 扣子智能体将在这里加载 -->
                </div>
            </div>
        </div>
    </main>

    <!-- 扣子智能体SDK -->
    <script src="https://lf-cdn.coze.cn/obj/unpkg/flow-platform/chat-app-sdk/1.2.0-beta.10/libs/cn/index.js"></script>
    <script>
        // 移动端菜单切换
        document.addEventListener('DOMContentLoaded', function() {
            // 移动端菜单切换
            const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
            const navUl = document.querySelector('nav ul');
            
            if (mobileMenuBtn && navUl) {
                mobileMenuBtn.addEventListener('click', function() {
                    navUl.classList.toggle('show');
                });
            }
            
            // 初始化扣子智能体
            try {
                const loadingIndicator = document.getElementById('loadingIndicator');
                
                const chatClient = new CozeWebSDK.WebChatClient({
                    container: '.coze-container', // 指定容器
                    config: {
                        bot_id: '7559540668603875354',
                        log_level: 'info'
                    },
                    componentProps: {
                        title: '班级智能助手',
                        placeholder: 'Send message',
                        style: {
                            width: '100%',
                            height: '100%',
                            borderRadius: '12px'
                        }
                    },
                    auth: {
                        type: 'token',
                        token: 'pat_U8fyzEn209s5Cgty4aTQjfcW2gFJoGHKnDaUN2quxiH08ulPnP0Twlr2OsyzaoMH',
                        onRefreshToken: function() {
                            console.log('刷新token');
                            return 'pat_U8fyzEn209s5Cgty4aTQjfcW2gFJoGHKnDaUN2quxiH08ulPnP0Twlr2OsyzaoMH';
                        }
                    },
                    events: {
                        onInit: function() {
                            console.log('智能体初始化成功');
                            // 隐藏加载提示
                            if (loadingIndicator) {
                                loadingIndicator.style.display = 'none';
                            }
                        },
                        onError: function(error) {
                            console.error('智能体初始化错误:', error);
                            // 显示错误提示
                            if (loadingIndicator) {
                                loadingIndicator.innerHTML = '<p style="color: var(--danger-color);"><i class="fas fa-exclamation-circle"></i> 智能助手加载失败，请刷新页面重试</p>';
                            }
                        }
                    }
                });
            } catch (error) {
                console.error('扣子智能体初始化异常:', error);
                const loadingIndicator = document.getElementById('loadingIndicator');
                if (loadingIndicator) {
                    loadingIndicator.innerHTML = '<p style="color: var(--danger-color);"><i class="fas fa-exclamation-circle"></i> 智能助手加载异常，请稍后再试</p>';
                }
            }
        });
    </script>
</body>
</html>